<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'Coupon';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'] ;

	$api->resource('coupons', "CouponController", ['only' => $allMethod]);
});

// 租户api
// $api->version('v1', ['prefix' => 'tenant-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Tenant\V1'], function ($api) {
// 	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
// });

// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];


	$api->get('/my-coupons', ['uses'=> "MyCouponController@index"]);

	
	$api->get('usable-coupons', ['uses'=> "CouponController@useableIndex"]);

	$api->get('coupons', ['uses'=> "CouponController@index"]);
	// 首页弹窗列表
	$api->get('coupon/popup-list', ['uses'=> "CouponController@popupIndex"]);
	// 领取首页弹窗中的优惠券
	$api->post('coupon/pick-popup', ['uses'=> "CouponController@pickPopup"]);
	$api->get('coupons/{uuid}', ['uses'=> "CouponController@show"]);
	$api->post('/coupons/{uuid}/pick', ['uses'=> "CouponPickController@store"]);
	$api->post('/pick-coupon', ['uses'=> "CouponPickController@storeWithCode"]);
});